package main.util;

import java.util.List;
import java.util.Map;

public class ArrayUtil {
	//链接数组的字符串
	public static String conectArray(String[] strs,String conect){
		StringBuffer sb=new StringBuffer();
		for(String str:strs){
			sb.append(str).append(conect);
		}
		return sb.substring(0, sb.length()-conect.length());
	}
	
	//链接数组的字符串
	public static String conectArray(List<String> strs,String conect){
		StringBuffer sb=new StringBuffer();
		for(String str:strs){
			if(str!=null && !"".equals(str))
				sb.append(str).append(conect);
		}
		return sb.substring(0, sb.length()-conect.length());
	}
	
	//判断map里面对应的value值，是否包含字符串str
	public static String containStringValue(Map<String,String> table,String str){
		if(StringUtil.isEmpty(str)){
			return null;
		}
		
		String colKey=null;
		for(String key : table.keySet()){
			if(table.get(key).indexOf(","+str+",")>0){
				colKey=key;
				break;
			}
		}
		return colKey;
	}
	
	public static void main(String[] args) {
		String ss="101,102,102";
		String out=conectArray(ss.split(","), ",");
		System.out.println(out);
	}
}
